library(ggplot2)
SNPs<- read.table("23andMe_complete.txt", header= TRUE, sep = "\t")
ex <- ggplot(data = SNPs) +
geom_bar(mapping = aes(x = chromosome), fill="blue")
ex + ggtitle("Chromosome Count") +
xlab("Chromosome Number") +
ylab("Nucleotide Count")
nt <- c("AA"="blue","AC"="blue","AG"="blue","AT"="blue","CC"="blue","CG"="blue","CT"="blue","GG"="blue","GT"="blue","TT"="blue","A"="red","G"="red","T"="red","C"="red","--"="yellow","D"="yellow","DD"="yellow","DI"="yellow","I"="yellow","II"="yellow")
SNPs$chromosome = ordered(SNPs$chromosome, levels=c(seq(1, 22), "X", "Y", "MT"))
ggplot(data = SNPs) +
geom_bar(mapping = aes(x = chromosome, fill=genotype)) +
scale_fill_manual(values=nt) +
ggtitle("Chromosome Count by Genotype") +
xlab("Chromosome Number") +
ylab("Nucleotide Count by Genotype")
ppi <- 300
png("SNP_ex3.png", width=6*ppi, res=ppi)
SNPs$chromosome = ordered(SNPs$chromosome, levels=c(seq(1, 22), "X", "Y", "MT"))
SNP <- ggplot(data = SNPs) +
geom_bar(mapping = aes(x = chromosome, fill = genotype), position = "dodge")
dev.off()
## quartz_off_screen
## 2
Genotype counts per chromosome
SNPs$chromosome = ordered(SNPs$chromosome, levels=c(seq(1, 22), "X", "Y", "MT"))
wrap <- ggplot(data = SNPs) +
geom_bar(mapping = aes(x = chromosome, fill = genotype), position = "dodge") +
facet_wrap(~ genotype, ncol = 3)
wrap + ggtitle("Genotype Frequencies on Chromosomes") +
xlab("Chromosome Number") +
ylab("Genotype Count")
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
SNPs$chromosome = ordered(SNPs$chromosome, levels=c(seq(1, 22), "X", "Y", "MT"))
ggplotly(
ggplot(data = SNPs) +
geom_bar(mapping = aes(x = chromosome, fill = genotype), position = "dodge") +
facet_wrap(~ genotype, nrow = 2)
)
YSNP <- subset(SNPs, chromosome=="Y")
library(DT)
datatable(YSNP)
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html